﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FieldTools.Util.Helper
{
    /// <summary>
    /// 进程帮助类
    /// </summary>
    public class ProcessHelper
    {
        /// <summary>
        /// 获取当前进程
        /// </summary>
        /// <returns></returns>
        public static Process GetTheProcess()
        {
            return Process.GetCurrentProcess();
        }
        /// <summary>
        /// 获取所有进程
        /// </summary>
        /// <returns></returns>
        public static List<Process> GrtProcesss()
        {
            return Process.GetProcesses().ToList();
        }
        /// <summary>
        /// 获取当前进程所有线程
        /// </summary>
        /// <returns></returns>
        public static List<ProcessThread> GetAllThreads()
        {
            Process process = Process.GetCurrentProcess();
            List<ProcessThread> threads = new();
            if (process == null)return threads;
            foreach (ProcessThread thread in process.Threads)
            {
                threads.Add(thread);
            }
            return threads;
        }
    }
}
